package com.nulstudio.sppm.Service;

import com.nulstudio.sppm.Dao.InventoryEntryMapper;
import com.nulstudio.sppm.Entities.InventoryEntry;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class InventoryEntryService {
    @Autowired
    private InventoryEntryMapper mapper;
    public List<InventoryEntry> getAllWarehouses(int id){
        return mapper.getAllWarehouses(id);
    }
    public int addWarehouse(InventoryEntry inventoryEntry){
        return mapper.addWarehouse(inventoryEntry);
    }

    public int modifyWarehouse(InventoryEntry inventoryEntry,int nid){
        return mapper.modifyWarehouse(inventoryEntry.getName(),inventoryEntry.getQuantity(),inventoryEntry.getSupplierName(),
                inventoryEntry.getCostPrice(),nid);
    }
    public int deleteWarehouse(int id){
        return mapper.deleteWarehouse(id);
    }

    public int transferEntry(int targetId,int warehouseId,int commodityId,int quantity){
        mapper.transferEntry1(warehouseId,commodityId,quantity);
        return mapper.transferEntry2(targetId,commodityId,quantity);
    }
}
